package com.bsc.rtc.lib.libraries.RxJavaRetrofitDemo;

import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.os.Bundle;
import android.util.Log;

import com.bsc.rtc.lib.libraries.R;
import com.jakewharton.rxbinding3.view.RxView;
import com.tbruyelle.rxpermissions2.RxPermissions;

import io.reactivex.disposables.Disposable;

public class RxPermissionDemoActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rx_permission_demo);
        init();
    }


    private void init() {
        final RxPermissions rxPermissions = new RxPermissions(this);
        Disposable disposable = RxView.clicks(findViewById(R.id.get_permission))
                .compose(rxPermissions.ensure(Manifest.permission.CAMERA))
                .subscribe(granted -> {
                    // R.id.enableCamera has been clicked
                    Log.i("zzw", "result==" + granted);
                });
    }

}
